package com.xxgc.eow.service.impl;

import com.xxgc.eow.entity.Answer;
import com.xxgc.eow.mapper.AnswerMapper;
import com.xxgc.eow.service.IAnswerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 答题提交记录 服务实现类
 * </p>
 *
 * @author Mr.Abel
 * @since 2023-06-04
 */
@Service
public class AnswerServiceImpl extends ServiceImpl<AnswerMapper, Answer> implements IAnswerService {

    @Resource
    private AnswerMapper answerMapper;

    @Override
    public Integer getAllByUserId(Integer userId) {
        return answerMapper.selectAllByUserId(userId);
    }

    @Override
    public Integer getAllPassByUserId(Integer userId) {
        return answerMapper.selectAllPassByUserId(userId);
    }

    @Override
    public Integer getAllUnPassByUserId(Integer userId) {
        return answerMapper.selectAllUnPassByUserId(userId);
    }

    @Override
    public Integer getCountByUserIdAndLevel(Integer userId, Integer level) {
        return answerMapper.selectCountByUserIdAndLevel(userId, level);
    }

    @Override
    public Integer getAnswerIdByUserIdAndTopicId(Integer userId, Integer topicId) {
        return answerMapper.selectIdByUserIdAndTopicId(userId, topicId);
    }

    @Override
    public List<Answer> getAllAnswer(Integer userId, Integer libraryId) {
        return answerMapper.selectAllAnswerByUserIdAndLibraryId(userId, libraryId);
    }

    @Override
    public Integer clearUserAnswer(Integer userId,Integer libraryId) {
        return answerMapper.updateByUserId(userId,libraryId);
    }
}
